﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Acoris.Media
{
    /// <summary>
    /// 
    /// </summary>
    public sealed class GradientStop
    {
        private double m_offset;
        private Color m_color;

        public GradientStop(double offset,Color color)
        {
            m_offset = offset;
            m_color = color;
        }

        /// <summary>
        /// 
        /// </summary>
        public double Offset {
            get { return m_offset; }
            set { m_offset = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public Color Color {
            get { return m_color; }
            set { m_color = value; }
        }

        #region Override

        /// <summary>
        /// 获取与当前对象等价的字符串形式
        /// </summary>
        /// <returns>返回与当前对象等价的字符串形式</returns>
        public override string ToString()
        {
            return base.ToString();
        }

        /// <summary>
        /// 获取当前对象与指定对象之间的等价性
        /// </summary>
        /// <param name="obj">指定要比较的对象</param>
        /// <returns>如果两个对象之间等价则返回true，否则返回false</returns>
        public override bool Equals(object obj)
        {
            if(obj is GradientStop stop) {
                return stop.m_color == this.m_color && stop.m_offset == this.m_offset;
            }
            return false;
        }

        /// <summary>
        /// 获取当前对象的哈希值
        /// </summary>
        /// <returns>返回当前对象的哈希值</returns>
        public override int GetHashCode()
        {
            return m_color.GetHashCode() ^ m_offset.GetHashCode();
        }
        #endregion

        public static bool operator == (GradientStop x,GradientStop y)
        {
            return x.m_color == y.m_color && x.m_offset == y.m_offset;
        }

        public static bool operator !=(GradientStop x,GradientStop y)
        {
            return x.m_color != y.m_color || x.m_offset != y.m_offset;
        }
    }
}
